package cn.donting.jme.swing;

import java.text.NumberFormat;
import java.text.ParseException;

public class JIntegerTextField extends JNumberTextField<Integer> {
    private NumberFormat numberFormat = NumberFormat.getIntegerInstance();

    public JIntegerTextField() {
        super(0,1);
    }

    @Override
    protected int compareTo(Integer n1, Integer n2) {
        return n1.compareTo(n2);
    }

    @Override
    protected Integer parse(String text) throws NumberFormatException {
        return Integer.parseInt(text);
    }

    @Override
    protected Integer format(String text) throws ParseException {
        Number parse = numberFormat.parse(text);
        return parse.intValue();
    }

    @Override
    protected Integer add(Integer value, Integer value2) {
        return value+value2;
    }

    @Override
    protected Integer subtraction(Integer value, Integer value2) {
        return value-value2;
    }

}
